package tech.summerly.weather.component.adapter.floors

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.floor_daily_forecast.view.*
import tech.summerly.weather.R
import tech.summerly.weather.component.adapter.DailyForecastAdapterVertical
import tech.summerly.weather.data.bean.DailyForecast
import tech.summerly.weather.util.ViewHolder

class DailyForecastFloor : BaseFloor<DailyForecast>() {

    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
        val inflated = inflater.inflate(R.layout.floor_daily_forecast, parent, false)
        return DailyFloor(inflated)
    }

    override fun onBindViewHolder(holder: ViewHolder, item: DailyForecast) {
        holder as DailyFloor
        holder.setData(item)
    }


    class DailyFloor(itemView: View) : ViewHolder(itemView) {

        private val adapter = DailyForecastAdapterVertical()

        init {
            itemView.recyclerDaily.adapter = adapter
        }

        fun setData(item: DailyForecast) {
            adapter.setDailyForecast(item)
        }
    }


}